package com.aaa.service.proxy;

import com.aaa.service.Service1;
import com.aaa.service.impl.Service1Impl;

public class StaticProxy implements Service1 {
    Service1Impl service1;

    public StaticProxy(Service1Impl service1) {
        this.service1 = service1;
    }

    @Override
    public void myService() {
        System.out.println("开启事务");
        service1.myService();
        System.out.println("提交事务");

    }
}

class Test {
    public static void main(String[] args) {
        Service1 service1 = (Service1) new StaticProxy(new Service1Impl());
        service1.myService();

    }
}
